<?php
/**
 *	[alias(alias.{modulename})] (C)2012-2099 Powered by abans@qq.com.
 *	Version: v1.0
 *	Date: 2012-10-17 09:40
 */
//error_reporting(E_ALL);
if(!defined('IN_DISCUZ')) {
	exit('Access Denied');
}
if($_G['adminid']!=1){return;}
if(!defined('Adz_class')){include('Adz.class.php');}
$otherurl = ADMINSCRIPT."?action=plugins&operation=config&identifier=push&pmod=list";
$table_log = 'plugin_push_log';
if($_GET['delall']=='7'){
	$mdate = date('Y-m-d',Adz::time_ex(Adz::get_time('time'),-7)).' 00:00:00';
	$ars = DB::delete($table_log, "date<'$mdate'");
	echo "<script>alert('".lang('plugin/push','del_success').$ars.lang('plugin/push','tiao')."');setTimeout(function(){location.href=\"$otherurl\";},1)</script>";
	exit;
}
if($_POST['act']=='del'){
	$ids = $_POST['ids'];
	$ars = DB::delete($table_log, "id in ($ids)");
	echo "$ars";
	exit;
}


$_G['setting']['memberperpage'] = 20;
$page = max(1, $_G['page']);
$start_limit = ($page - 1) * $_G['setting']['memberperpage'];
$type_op = array(
	'1'=>lang('plugin/push','mail'),
	'2'=>lang('plugin/push','weixin'),
	'3'=>lang('plugin/push','weibo'),
);
$status_op = array(
	'0'=>lang('plugin/push','stat0'),
	'1'=>lang('plugin/push','stat1'),
	'2'=>lang('plugin/push','stat2'),
	'4'=>lang('plugin/push','stat4'),
);
$member = array();
$where = '';
if($_GET['status'] || (isset($_GET['status']) && $_GET['status']==0)){
	$where = 'and a.status='.$_GET['status'];
}
$counts = DB::fetch_first('SELECT COUNT(a.id) as num FROM '.DB::table($table_log).' a WHERE 1 '.$where.' LIMIT 1');
$membernum = $counts['num'];
if($membernum > 0) {
	$multipage = multi($membernum, $_G['setting']['memberperpage'], $page, $otherurl);
	$sql = 'SELECT a.*,m.username FROM '.DB::table($table_log).' a LEFT JOIN '.DB::table('common_member').' m ON m.uid=a.uid WHERE 1 '.$where.' ORDER BY a.id DESC LIMIT '.$start_limit.',20';
	$data = Adz::fetch_all($sql);
}
include_once template("push:list");